﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Chromos.ActionEngine;
using Chromos.AIEngine;

namespace Chromos.Actors
{
	class SnowMan : Enemy
    {
        const int moveSpeed = 80;

        public SnowMan(Game1 game, Vector2 position, Vector2 velocity, ContentManager content, bool isStatic, string aggressiveness)
			: base(game, position, velocity, content, isStatic,  aggressiveness)
		{
			this.applyGravity = true;
		}

        protected override void initAIEngine()
		{
			aiEngine = new MinionAIEngine(this, "normal", 300);
		}

		protected override void initActorFields()
		{
			base.initActorFields();
			this.health = 100;
		}

		public override Projectile createProjectiles(int i)
		{
			switch (i)
			{
				case 0:
					return leftGunP();
				case 1:
					return rightGunP();
				default:
					return null;
			}
		}
		private Projectile leftGunP()
		{
			Vector2 v = new Vector2(0, 0);
			v.X = -400;
			Vector2 p = new Vector2(this.position.X, this.position.Y);
			p.X -= 20;
			return new IceBullet(this.game, p, v, this.game.Content, false, this, 0, null);
		}
		private Projectile rightGunP()
		{
			Vector2 v = new Vector2(0, 0);
			v.X = 400;
			Vector2 p = new Vector2(this.position.X, this.position.Y);
			p.X += 20;
			return new IceBullet(this.game, p, v, this.game.Content, false, this, 0, null);
		}

		public override void addActions()
		{
            // Create and add the various actions for this actor's idling, movement, attack, and defense.
            // NOTE: Uses VisualLoopingAction until VisualNonLoopingAction is made non-abstract.

            // SnowMan Idle (nonLooping)
			IdleAction hover = new IdleAction(this, content, Vector2.Zero, ForceType.ForceInstant, 0);
			hover.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Move/SnowStanding");


            // SnowMan Jump Left
			WalkAction jumpLeft = new WalkAction(this, content, new Vector2(-10, -12.6f), ForceType.ForceContinuous, 500, FACING.LEFT);
            jumpLeft.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Move/Jump/SnowJump2");
			jumpLeft.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Move/SnowStanding");
			jumpLeft.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Move/Jump/SnowJump1");

            // SnowMan Move Right
			WalkAction jumpRight = new WalkAction(this, content, new Vector2(10, -12.6f), ForceType.ForceContinuous, 500, FACING.RIGHT);
			jumpRight.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Move/Jump/SnowJump2");
			jumpRight.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Move/SnowStanding");
			jumpRight.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Move/Jump/SnowJump1");

			AttackAction attLeft = new AttackAction(this, content, new Vector2(0, 0), ForceType.ForceInstant, 250, createProjectiles, 0, 0, 150, 400, 0, 100, 100, null, null, FACING.LEFT, false);
			attLeft.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Attacks/SnowLeft1");
			attLeft.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Attacks/SnowLeft2");
			AttackAction attRight = new AttackAction(this, content, new Vector2(0, 0), ForceType.ForceInstant, 250, createProjectiles, 0, 0, 150, 400, 0, 100, 100, null, null, FACING.RIGHT, false);
			attRight.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Attacks/SnowRight1");
			attRight.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Attacks/SnowRight2");

			DeathAction death = new DeathAction(this, content, new Vector2(0, 0), ForceType.ForceInstant, 100);
			death.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Death/SnowDeath1");
			death.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Death/SnowDeath2");
			death.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Death/SnowDeath3");
			death.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Death/SnowDeath4");
			death.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Death/SnowDeath5");
			death.addImageToLoad(@"Sprites/Enemies/WhiteUnits/SnowMan/Death/SnowDeath6");

			// Add everything to the correct action list
			actionEngine.addIdle(hover);
			actionEngine.addMovement(jumpLeft);
			actionEngine.addMovement(jumpRight);
			actionEngine.addAttack(attLeft);
			actionEngine.addAttack(attRight);
			actionEngine.addDeath(death);
		}
    }
}
